package com.shensi.api.pay.client;

import com.alibaba.fastjson.JSONObject;
import com.shensi.api.pay.param.request.*;
import com.shensi.api.pay.param.vo.CouponUserVO;
import com.shensi.api.pay.pojo.InvoiceInfoVo;
import com.shensi.common.core.constant.CloudConstant;
import com.shensi.api.pay.param.ResultData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;

/***
 * <Title> QuJiaPayController </Title>
 * <Description> 趣加 新版小程序订单 App生成订单，与调用第三方支付控制层 </Description>
 * <Date>2021年10月28日</Date>
 */

@Api(tags = "趣加App支付")
@FeignClient(name = CloudConstant.PAY_SERVER)
public interface QuJiaPayV2Client {


    /*
     * 小程序创建加油支付订单
     * @param payOrderRequest
     * @return
     */
    @ApiOperation(value = "小程序创建加油支付订单", httpMethod = "POST", notes = "小程序创建加油支付订单")
    @PostMapping(value = "/createOrder", produces = "application/json;charset=UTF-8")
    @Transactional(rollbackFor = Exception.class)
    public String createOrder(@RequestBody PayOrderRequest request);

    @ApiOperation(value = "自动切换支付渠道", httpMethod = "POST", notes = "自动切换支付渠道")
    @PostMapping(value = "/changeAutoPayWay", produces = "application/json;charset=UTF-8")
    public int changeAutoPayWay(@RequestBody AutoPayWay autoPayWay);

    @ApiOperation(value = "创建订单不包含任何优惠活动", httpMethod = "POST", notes = "创建订单不包含任何优惠活动")
    @PostMapping(value = "/createOrderNotContainActivity", produces = "application/json;charset=UTF-8")
    @Transactional(rollbackFor = Exception.class)
    public String createOrderNotContainActivity(@RequestBody PayOrderRequest request);

    /*
     * 小程序创建加油支付订单
     * @param payOrderRequest
     * @return
     */
    @ApiOperation(value = "根据电子卡计算优惠", httpMethod = "POST", notes = "根据电子卡计算优惠")
    @PostMapping(value = "/updateOrderByDzk", produces = "application/json;charset=UTF-8")
    @Transactional(rollbackFor = Exception.class)
    public String updateOrderByDzk(@RequestBody PayOrderRequest request);


    /*
     * 小程序创建加油支付订单
     * @param payOrderRequest
     * @return
     */
    @ApiOperation(value = "有优惠卷创建订单", httpMethod = "POST", notes = "有优惠卷创建订单")
    @PostMapping(value = "/updateOrderByCoupon", produces = "application/json;charset=UTF-8")
    @Transactional(rollbackFor = Exception.class)
    public String updateOrderByCoupon(@RequestBody PayOrderRequest request);


    /*
     * 小程序消费支付拉起第三方支付
     * @param payInfoRequest
     * @return
     */
    @ApiOperation(value = "消费支付拉起第三方支付", httpMethod = "POST", notes = "消费支付拉起第三方支付")
    @PostMapping(value = "/toThirdPay")
    @Transactional
    public String toThirdPay(@RequestBody PayInfoRequest payInfoRequest);


    /*
     * 小程序消费支付拉起第三方支付
     * @param payInfoRequest
     * @return
     */
    @ApiOperation(value = "消费支付拉起第三方支付", httpMethod = "POST", notes = "消费支付拉起第三方支付")
    @PostMapping(value = "/toThirdPayV2")
    @Transactional
    public String toThirdPayV2(@RequestBody PayInfoRequest payInfoRequest);


    @ApiOperation(value = "支付成功修改优惠卷状态", httpMethod = "POST", notes = "修改优惠卷状态")
    @PostMapping(value = "/updateCouponUser")
    public ResultData updateCouponUser(@RequestBody CouponUserVO couponUserId);

    /*
     * 小程序消费  随行付异步回调通知
     * @param request
     * @return
     * @throws ParseException
     */
    @RequestMapping(value = "/sxfPayCallbackV2", consumes = "application/json", method = RequestMethod.POST)
    public JSONObject sxfPayCallbackV2(@RequestBody JSONObject request);

    // 金控接受异步异步通知
    @RequestMapping(value = "/JKNotice", consumes = "application/json", method = RequestMethod.POST)
    public void JKNotice(@RequestParam("request") HttpServletRequest request, @RequestParam("response") HttpServletResponse response);


    //电子卡支付
    @Transactional
    @RequestMapping(value = "/dzkPaySetV2", method = RequestMethod.GET)
    @ApiOperation(value = "电子卡支付", httpMethod = "GET", notes = "电子卡支付")
    public String dzkPaySet(@RequestParam("ordNo") String ordNo, @RequestParam(value = "couponUserId", required = false) String couponUserId);

    @RequestMapping(value = "/consumptionCouponIssuance", method = RequestMethod.GET)
    @ApiOperation(value = "消费后发券", httpMethod = "GET", notes = "消费后发券retCode为0则成功，为其他的则不跳转，非空判断返回值为空也不跳转")
    public String consumptionCouponIssuance(@RequestParam("ordNo") String ordNo, @RequestParam(value = "amt", required = false) Double amt);

    //电子卡支付
    @Transactional
    @RequestMapping(value = "/newDzkCouponPaySetV3", method = RequestMethod.GET)
    @ApiOperation(value = "电子卡支付", httpMethod = "GET", notes = "电子卡支付")
    public ResultData newDzkCouponPaySetV3(@RequestParam("ordNo") String ordNo, @RequestParam(value = "couponUserId", required = false) String couponUserId,
                                           @RequestParam(required = false,value = "payType",defaultValue = "dzk_wx") String payType,
                                           @RequestParam(required = false, value = "genericPay",defaultValue = "false") boolean genericPay);


    // 金控接受异步异步通知
    @RequestMapping(value = "/yunHuaNotice", consumes = "application/json", method = RequestMethod.POST)
    public void yunHuaNotice(@RequestParam("request") HttpServletRequest request, @RequestParam("response") HttpServletResponse response);


    // 金控接受异步异步通知
    @RequestMapping(value = "/test11", consumes = "application/json", method = RequestMethod.POST)
    public void test11();


    /**
     * 天阙支付-刷卡支付创建订单
     */
    @ApiOperation(value = "天阙支付-刷卡支付创建订单")
    @PostMapping("/tradeReverseBankCardAddOrder")
    @ResponseBody
    public String tradeReverseBankCardAddOrder(@Valid @RequestBody AddPayOrderParam payParameter);

    /**
     * 天阙支付-刷卡支付前端更新订单
     */
    @ApiOperation(value = "天阙支付-刷卡支付前端更新订单")
    @PostMapping("/bankCardUpdateOrder")
    @ResponseBody
    public String bankCardUpdateOrder(@Valid @RequestBody BankCardUpdateOrderParam param);

    /**
     * 开小票
     *
     * @param invoice 小票信息
     * @return
     */
    @ApiOperation(value = "去开票", httpMethod = "POST", notes = "开发票")
    @PostMapping("/goToInvoice")
    @ResponseBody
    @Transactional
    public String goToInvoice(@Valid @RequestBody GoToInvoice invoice);

    @ApiOperation(value = "获取订单开票状态")
    @GetMapping("/getInvoiceStatus")
    @ResponseBody
    public String getInvoiceStatus(@RequestParam("OrderNo") String OrderNo);

    @ApiOperation(value = "获取订单开票记录")
    @GetMapping("/getInvoiceRecords")
    @ResponseBody
    public List<InvoiceInfoVo> getInvoiceRecords(@RequestParam("OrderNo") String OrderNo);
}
